<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>axios 全局配置</title>
</head>
<body>
<div id="app">

</div>
<script src="../../../../js/axios.js"></script>
<script type="module">
  import {createApp, onMounted} from "../../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup(){
              // 配置全局基于网址
              axios.defaults.baseURL = "https://www.httpbin.org"
              axios.defaults.timeout = 5000
              async function getRequest() {
                try {
                  let response = await axios.get(
                          "/get",
                          {
                            params: {
                              name: "abcque",
                              age: 18,
                              gender: "M",
                            }

                          }
                  );

                  console.log(response);

                } catch (e) {
                  console.log(e);
                }

              }

              onMounted(
                      () => {
                        getRequest()
                      }
              )
                return {}
            }
        }
    )
    app.mount("#app")
</script>
</body>
</html>